import store from "@/store/index"
import appStore from "@/store/app";
import {AxiosInstance} from "axios"

/**
 * 获取当前项目配置
 */
const AppStore = appStore(store)
let path = AppStore.$state.ext.path


// @ts-ignore 载入全部http请求库
const http: { [key: string]: { default: Function, getInstance: Function } } = import.meta.glob(`@/apps/**/units/request.ts`, {eager: true})

/**
 * 获取axios实例
 */
export const axios: AxiosInstance = http[`/src/apps/${path}/units/request.ts`].getInstance()

/**
 * 导出请求
 */
export default http[`/src/apps/${path}/units/request.ts`].default